package com.ktjy.service.impl;

import com.ktjy.entity.Supplier;
import com.ktjy.mapper.SupplierMapper;
import com.ktjy.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
@Service("supplierService")
public class SupplierServiceImpl implements SupplierService {
    @Autowired
    private SupplierMapper supplierMapper;

    @Override
    public List<Supplier> getSupplierList(Supplier supplier) {
        return supplierMapper.getSupplierList(supplier);
    }
    public void setSupplierMapper(SupplierMapper supplierMapper) {
        this.supplierMapper = supplierMapper;
    }

    @Override
    @Transactional
    public int insert(List<Supplier> supplierList) {
        int rows=0;
        for (int i = 0; i < supplierList.size(); i++) {
            Supplier supplier=supplierList.get(i);
            rows+=supplierMapper.insert(supplier);
        }
        return rows;
    }

    @Override
    @Transactional
    public int delete(Supplier supplier) {
        return supplierMapper.delete(supplier);
    }

    @Override
    @Transactional
    public int update(Supplier supplier) {
        return supplierMapper.update(supplier);
    }
}
